#include "SceneHome.h"
#include "cocostudio/CocoStudio.h"
#include "ui/CocosGUI.h"
#include "deprecated/CCDeprecated.h"
#include "ui/UIHelper.h"
#include "base/CCConsole.h"

#include "LayerHomeTop.h"
#include "LayerHomeDown.h"

USING_NS_CC;
using namespace ui;

CSceneHome::CSceneHome(void) : m_Home(nullptr), m_TopLayer(nullptr), m_DownLayer(nullptr), m_MiddleLayer(nullptr), m_ContainerPack(nullptr)
{
}


CSceneHome::~CSceneHome(void)
{
}

bool CSceneHome::init() {
	// 1. super init first
    if ( !CSceneBase::init() )
    {
        return false;
    }
    
	m_TopLayer = m_LayerManager->GetLayer(CLayerManager::LayerIHomeTop);
	m_MiddleLayer = m_LayerManager->GetLayer(CLayerManager::LayerIHomeMiddle);
	m_DownLayer = m_LayerManager->GetLayer(CLayerManager::LayerIHomeDown);
	addChild(m_MiddleLayer);
	addChild(m_DownLayer);
	addChild(m_TopLayer);

	const Size& tThisSize = this->getContentSize();
	const Size& tTopSize = m_TopLayer->getContentSize();
	m_TopLayer->setPosition(0, tThisSize.height - tTopSize.height);
	const Size& tDownSize = m_DownLayer->getContentSize();
	m_DownLayer->setPosition(0, 0);

    return true;
}

/*
void CSceneHome::onEnter() {
	cocos2d::Scene::onEnter();
}
void CSceneHome::onExit() {
	cocos2d::Scene::onExit();
}

void CSceneHome::update(float delta) {
	cocos2d::Scene::update(delta);
}
*/

//void CSceneHome::onOpenPack(cocos2d::Ref* pSender, cocos2d::ui::TouchEventType type) {
//	switch (type)
//	{
//	case cocos2d::ui::TOUCH_EVENT_ENDED:
//		if (nullptr == m_ContainerPack) {
//			m_ContainerPack = CSLoader::createNode("Inventory.csb");
//			addChild(m_ContainerPack);
//		} else {
//			m_ContainerPack->setVisible(true);
//		}
//		break;
//	}
//}
